<html xmlns:th="https://www.thymeleaf.org"
      th:replace="~{fragments/layout :: layout (~{::body},'owners')}">

<body>

<h2>
    <th:block th:if="${pet['new']}">更新</th:block>
    宠物
</h2>
<form th:object="${pet}" class="form-horizontal" method="post">
    <input type="hidden" name="id" th:value="*{id}"/>
    <div class="form-group has-feedback">
        <div class="form-group">
            <label class="col-sm-2 control-label">所属者</label>
            <div class="col-sm-10">
                <span th:text="${pet.owner?.firstName + ' ' + pet.owner?.lastName}"/>
            </div>
        </div>
        <input
                th:replace="~{fragments/inputField :: input ('名字', 'name', 'text')}"/>
        <input
                th:replace="~{fragments/inputField :: input ('生日', 'birthDate', 'date')}"/>
        <input
                th:replace="~{fragments/selectField :: select ('种类', 'type', ${types})}"/>
    </div>
    <div class="form-group">
        <div class="col-sm-offset-2 col-sm-10">
            <button
                    th:with="text=${pet['new']} ? '新增宠物' : '更新宠物信息'"
                    class="btn btn-default" type="submit" th:text="${text}">新增宠物
            </button>
        </div>
    </div>
</form>

</body>

</html>